home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 12.2 KB | 441 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPartng.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWCNTPRP_H
- #include "FWCntPrp.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- #ifndef FWLNKMGR_H
- #include "FWLnkMgr.h"
- #endif
-
- #ifndef FWCMD_H
- #include "FWCmd.h"
- #endif
-
- #ifndef FWPROXY_H
- #include "FWProxy.h"
- #endif
-
- #ifndef FWPRMISE_H
- #include "FWPrmise.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWCLNINF_H
- #include "FWClnInf.h"
- #endif
-
- #ifndef FWINTRNG_H
- #include "FWIntrng.h"
- #endif
-
- #ifndef FWCONTNT_H
- #include "FWContnt.h"
- #endif
-
- // ----- OD Utils -----
-
- #ifndef _STDTYPIO_
- #include "StdTypIO.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Foci_defined
- #include <Foci.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifdef FW_BUILD_WIN
-
- #include <plfmdef.h>
- #include <t_regist.h>
-
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fw_embedding
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CEmbeddingPart, FW_CPart)
-
- //========================================================================================
- // class FW_CEmbeddingPart
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::FW_CEmbeddingPart
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingPart::FW_CEmbeddingPart(ODPart* odPart,
- FW_Instance partInstance,
- FW_ResourceID partInfoID) :
- FW_CPart(odPart, partInstance, partInfoID),
- fProxys(NULL),
- fNextFrameGroup(0)
- #ifdef FW_BUILD_WIN
- ,fWinEmbedMenu(NULL)
- #endif
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::~FW_CEmbeddingPart
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingPart::~FW_CEmbeddingPart()
- {
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::LinkStatusChanged
- //---------------------------------------------------------------------------------------
-
- void FW_CEmbeddingPart::LinkStatusChanged(Environment *ev, ODFrame* odFrame)
- {
- // The following code is default behavior for parts that don't create links.
-
- FW_CEmbeddingFrame* frame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, odFrame);
- if (frame)
- {
- ODLinkStatus linkStatus = odFrame->GetLinkStatus(ev);
-
- // You only need to propagate linkStatus to embedded frames that don't participate in
- // any of this part's links; otherwise their local link status takes precedence.
-
- FW_CPartEmbeddedFrameIterator iter(ev, this);
- for (ODFrame* odEmbeddedFrame = iter.First(ev); iter.IsNotComplete(ev); odEmbeddedFrame = iter.Next(ev))
- odEmbeddedFrame->ChangeLinkStatus(ev, linkStatus);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::ReleaseAll
- //----------------------------------------------------------------------------------------
- // Call inherited first when overrided
-
- void FW_CEmbeddingPart::ReleaseAll(Environment *ev)
- {
- // ----- Release all display Frames
- if (fProxys)
- {
- FW_CPartProxyIterator ite(this);
- for (FW_MProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
- {
- proxy->ReleaseAll(ev);
- }
- }
-
- FW_CPart::ReleaseAll(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::GetProxy
- //---------------------------------------------------------------------------------------
-
- FW_MProxy* FW_CEmbeddingPart::GetProxy(Environment* ev, ODFrame* embeddedFrame) const
- {
- FW_ASSERT(embeddedFrame != NULL);
-
- ODID embeddedFrameID = embeddedFrame->GetID(ev);
-
- FW_CPartProxyFrameIterator ite(this);
- for (FW_CProxyFrame* proxyFrame = ite.First(); ite.IsNotComplete(); proxyFrame = ite.Next())
- {
- if (proxyFrame->GetFrameID(ev) == embeddedFrameID)
- return proxyFrame->GetProxy(ev);
- }
-
- return NULL;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::CloneInto
- //---------------------------------------------------------------------------------------
-
- void FW_CEmbeddingPart::CloneInto(Environment *ev,
- ODDraftKey key,
- ODStorageUnit* toSU,
- ODFrame* scope)
- {
- // avoid changing the header for now, if it works, then delete this method
- FW_CPart::CloneInto(ev, key, toSU, scope);
-
- #ifdef DEADCODE
- ODStorageUnit* su = GetStorageUnit(ev);
- ODDraft* fromDraft = su->GetDraft(ev);
-
- FW_ASSERT((scope == NULL) || (scope != NULL && IsValidDisplayFrame(ev, scope->GetID(ev))));
-
- FW_CFrame *frame = scope == NULL ? NULL : FW_CFrame::ODtoFWFrame(ev, scope);
- FW_ASSERT((scope == NULL) || (scope != NULL && frame != NULL));
-
- FW_CCloneInfo cloneInfo(ev, key, fromDraft, frame, 0); // fromDraft->GetCloneKind(ev)
-
- // ----- Prepare the storage Unit and Externalize the content -----
- FW_ASSERT(toSU->GetDraft(ev)->GetPermissions(ev) >= kODDPSharedWrite);
- PrepContentProperty(ev, toSU, FW_kPartStorage, TRUE);
- FW_CContent* content = GetContent(ev);
- if (content)
- content->Externalize(ev, toSU, FW_kPartStorage, &cloneInfo);
- #endif
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::PrivAddProxy
- //---------------------------------------------------------------------------------------
-
- void FW_CEmbeddingPart::PrivAddProxy(Environment* ev, FW_MProxy* proxy)
- {
- FW_UNUSED(ev);
- if (fProxys == NULL)
- fProxys = FW_NEW(FW_TOrderedCollection<FW_MProxy>, ());
-
- fProxys->AddLast(proxy);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::PrivRemoveProxy
- //---------------------------------------------------------------------------------------
-
- void FW_CEmbeddingPart::PrivRemoveProxy(Environment* ev, FW_MProxy* proxy)
- {
- FW_UNUSED(ev);
- FW_ASSERT(fProxys);
-
- fProxys->Remove(proxy);
- if (fProxys->Count() == 0)
- {
- delete fProxys;
- fProxys = NULL;
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::NewDataInterchange
- //---------------------------------------------------------------------------------------
-
- FW_CDataInterchange* FW_CEmbeddingPart::NewDataInterchange(Environment* ev)
- {
- return new FW_CEmbeddingDataInterchange(ev, this);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::Purge
- //---------------------------------------------------------------------------------------
-
- ODSize FW_CEmbeddingPart::Purge(Environment *ev, ODSize size)
- {
- ODSize freedSize = FW_CPart::Purge(ev, size);
-
- // ----- Try purging all purgeable embedded frames -----
- FW_CPartProxyIterator ite(this);
- for (FW_MProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
- {
- freedSize += proxy->Purge(ev);
- }
-
- return freedSize;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::AcquireContainingPartProperties
- //---------------------------------------------------------------------------------------
-
- ODStorageUnit* FW_CEmbeddingPart::AcquireContainingPartProperties(Environment* ev,
- ODFrame* embeddedFrame)
- {
- ODStorageUnit *su = NULL;
-
- FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);
-
- FW_MContainingPropertiesFrame* containingProps = FW_DYNAMIC_CAST(FW_MContainingPropertiesFrame, embeddingFrame);
-
- if (containingProps != NULL)
- su = containingProps->AcquirePropertiesStorage(ev, GetDraft(ev));
-
- return su;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::EmbeddedFrameRemoved
- //---------------------------------------------------------------------------------------
-
- void FW_CEmbeddingPart::EmbeddedFrameRemoved(Environment *ev, FW_MProxy* proxy)
- {
- FW_UNUSED(ev);
- FW_UNUSED(proxy);
- FW_DEBUG_MESSAGE("Your part needs to implement FW_CEmbeddingPart::EmbeddedFrameRemoved");
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::PrivSetNextFrameGroup
- //---------------------------------------------------------------------------------------
- // Call by FW_MProxy::Internalize
-
- void FW_CEmbeddingPart::PrivSetNextFrameGroup(Environment *ev, ODID frameGroup)
- {
- FW_UNUSED(ev);
- if (frameGroup > fNextFrameGroup)
- fNextFrameGroup = frameGroup;
- }
-
- #ifdef FW_BUILD_WIN
- //------------------------------------------------------------------------------
- // FW_CEmbeddingPart::WinAddEmbedMenu
- //------------------------------------------------------------------------------
-
- void FW_CEmbeddingPart::WinAddEmbedMenu(Environment *ev, FW_CMenuBar *menuBar)
- {
- ODPartRegistryIterator iter;
- ODPartRegistryData data;
- char partString[50];
- LPSTR partPtr, tmpPtr;
-
- unsigned short partCount = -1; //TAG - this will increment the 1st time to 0 to
- // exclude the omnipresent IDM_DRAW part...
-
- unsigned short stringIndex = 0; // This indexes into part type string buffer.
- fWinFirstPartID = FW_kFirstUserCommandID + 0x8000;
-
- fWinEmbedMenu = new FW_CPullDownMenu(ev, FW_CString32("Embed"));
-
- for (iter.First(kODTrue,&data);iter.IsNotComplete();iter.Next(&data))
- {
- partCount++;
-
- // Keep the last word of the partKind
- FW_PrimitiveStringCopy(data.partKind, partPtr=partString);
- tmpPtr = partPtr;
- while (tmpPtr != NULL)
- {
- tmpPtr = FW_PrimitiveStringFindCharacter(partPtr, ':');
- if (tmpPtr != NULL)
- partPtr = ++tmpPtr;
- }
-
- FW_CString255 name(partPtr);
- fWinEmbedMenu->AppendTextItem(ev, name, fWinFirstPartID + partCount);
-
- fTypePtr[partCount] = &(fTypeString[stringIndex]);
- FW_PrimitiveStringCopy(data.partKind, fTypePtr[partCount]);
- stringIndex += FW_PrimitiveStringLength(fTypePtr[partCount]) + 1;
- }
- fWinLastPartID = fWinFirstPartID + partCount;
-
- menuBar->AdoptMenuLast(ev, fWinEmbedMenu);
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::WinCreateEmbeddedPartFromCommand
- //----------------------------------------------------------------------------------------
-
- ODPart* FW_CEmbeddingPart::WinCreateEmbeddedPartFromCommand(Environment* ev, ODCommandID commandID)
- {
- if ((commandID >= fWinFirstPartID) && (commandID <= fWinLastPartID))
- {
- return GetDraft(ev)->CreatePart(ev, fTypePtr[commandID - fWinFirstPartID], NULL);
- }
-
- return NULL;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingPart::WinEnableEmbedMenu
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingPart::WinEnableEmbedMenu(Environment* ev, FW_CMenuBar* menuBar)
- {
- if (fWinEmbedMenu != NULL && fWinEmbedMenu->GetMenuBar(ev) == menuBar)
- {
- fWinEmbedMenu->EnableAll(ev);
- }
- }
- #endif
-
-
-